package com.zhumei.keyscale.util;

import android.content.*;
import android.net.*;
import java.io.*;
import java.net.*;

public class NetworkDetector
{
    public static boolean isNetConnection(final Context context) {
        if (context != null) {
            final NetworkInfo activeNetworkInfo = ((ConnectivityManager)context.getSystemService("connectivity")).getActiveNetworkInfo();
            final boolean connected = activeNetworkInfo.isConnected();
            if (activeNetworkInfo != null && connected && activeNetworkInfo.getState() == NetworkInfo$State.CONNECTED) {
                return true;
            }
        }
        return false;
    }
    
    public static boolean isOnline() {
        try {
            new URL("https://www.baidu.com").openStream();
            return true;
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
        catch (MalformedURLException ex2) {
            ex2.printStackTrace();
        }
        return false;
    }
}
